package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.BusSpjgArea;
import com.ruoyi.business.service.IBusSpjgAreaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;


/**
 * 食品加工园园区概况Controller
 * 
 * @author ruoyi
 * @date 2023-07-21
 */
@Api(tags = "食品加工-园区概况")
@RestController
@RequestMapping("/spjg/overview")
public class BusSpjgAreaController extends BaseController
{
    @Autowired
    private IBusSpjgAreaService busSpjgAreaService;

    /**
     * 查询食品加工园园区概况列表
     */
    @ApiOperation("列表")
    @GetMapping("/list")
    public TableDataInfo list(BusSpjgArea busSpjgArea)
    {
        startPage();
        List<BusSpjgArea> list = busSpjgAreaService.selectBusSpjgAreaList(busSpjgArea);
        return getDataTable(list);
    }

    /**
     * 导出食品加工园园区概况列表
     */
    @PreAuthorize("@ss.hasPermi('spjg:overview:export')")
    @Log(title = "食品加工园园区概况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusSpjgArea busSpjgArea)
    {
        List<BusSpjgArea> list = busSpjgAreaService.selectBusSpjgAreaList(busSpjgArea);
        ExcelUtil<BusSpjgArea> util = new ExcelUtil<BusSpjgArea>(BusSpjgArea.class);
        util.exportExcel(response, list, "食品加工园园区概况数据");
    }

    /**
     * 获取食品加工园园区概况详细信息
     */
    @PreAuthorize("@ss.hasPermi('spjg:overview:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(busSpjgAreaService.selectBusSpjgAreaById(id));
    }

    /**
     * 新增食品加工园园区概况
     */
    @PreAuthorize("@ss.hasPermi('spjg:overview:add')")
    @Log(title = "食品加工园园区概况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusSpjgArea busSpjgArea)
    {
        return toAjax(busSpjgAreaService.insertBusSpjgArea(busSpjgArea));
    }

    /**
     * 修改食品加工园园区概况
     */
    @PreAuthorize("@ss.hasPermi('spjg:overview:edit')")
    @Log(title = "食品加工园园区概况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusSpjgArea busSpjgArea)
    {
        return toAjax(busSpjgAreaService.updateBusSpjgArea(busSpjgArea));
    }

    /**
     * 删除食品加工园园区概况
     */
    @PreAuthorize("@ss.hasPermi('spjg:overview:remove')")
    @Log(title = "食品加工园园区概况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(busSpjgAreaService.deleteBusSpjgAreaByIds(ids));
    }
}
